
#include "ROB_RC.h"
#include "ROB_IrRC.h"
#include "ROB_AppleRC.h"




void CAppleRC::Begin(void) {
  IR_remote_init(REMOTE_WITH_REPEAT);
}



uint8_t CAppleRC::update(void) {
  if(! IR_remote_available) {
    return 0;
  }
  RC.message(RCCMD_IR_REMOTE_BTN, dispatchCmd(IR_remote_data));
  IR_remote_init(REMOTE_WITH_REPEAT);
  return 1;

}



uint8_t CAppleRC::dispatchCmd(uint32_t code) {

  uint8_t apple = (code >> 8) & 0xFF;

  switch (apple) {
  case 0xD0:
    return(IR_REMOTE_BTN_UP);
    break;
  case 0xB0:
    return(IR_REMOTE_BTN_DN);
    break;
  case 0x10:
    return(IR_REMOTE_BTN_LE);
    break;
  case 0xE0:
    return(IR_REMOTE_BTN_RE);
    break;
  case 0x20:
    return(IR_REMOTE_BTN_CC);
    break;
  case 0x40:
    return(IR_REMOTE_BTN_MM);
    break;
  default:
    return(IR_REMOTE_BTN_NONE);
    break;
  }
}




CAppleRC AppleRC;

